#include "common/pch.h"

#include <format>

#include <cftc/reflect/class.h>
#include <cftc/reflect/field.h>
#include <cftf/loger/syslog.h>

#include "object/transport.h"
#include "object/unit.h"

namespace battle::object
{

    Transport::Transport()
    {
        m_updateFlag = (UPDATEFLAG_TRANSPORT | UPDATEFLAG_ALL | UPDATEFLAG_HAS_POSITION);
    }

    Transport::~Transport()
    {

    }

    bool Transport::AddPassenger(Unit* passenger)
    {
        if (m_passengers.find(passenger) == m_passengers.end()) {
            cftf::loger::SysLog::Instance().Warning(std::format("{} boarded transport {}.", passenger->GetGuidStr().c_str(), GetName()));
            m_passengers.insert(passenger);
        }
        return true;
    }

    bool Transport::RemovePassenger(Unit* passenger)
    {
        if (m_passengers.erase(passenger)) {
            cftf::loger::SysLog::Instance().Warning(std::format("{} removed from transport {}.", passenger->GetGuidStr().c_str(), GetName()));
        }
        return true;
    }

}